home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: aril@cmt.lpr.mail.carel.fi (Ari Lukumies)
- Newsgroups: comp.lang.c++
- Subject: Re: How to initialize an array of structures?
- Date: Thu, 11 Jan 1996 13:55:10 GMT
- Organization: Carelcomp Forest Oy
- Message-ID: <4d358f$kj9@tahko.lpr.carel.fi>
- References: <4d240e$nk5@jupiter.planet.net>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- X-Newsreader: Forte Free Agent 1.0.82
-
- Chris Kemp <chrisk@paladn.com> wrote:
-
- >Could someone explain how to do this properly:
-
- > struct FUNCTIONMAP
- > {
- > char *functionname;
- > int functionnumber;
- > int maxargs;
- > int functarg[5];
- >
- > };
- >
- > static struct FUNCTIONMAP functionlist[300];
- > functionlist[1]={"firstfunction",1,3,2,2,2,0,0} <-- hangs on this line
- >
- >TIA
-
- You would want to use braces:
-
- static struct FUNCTIONMAP functionlist[300];
-
- functionlist[0] = { "firstfunction", 1, 3, { 2, 2, 2, 0, 0 } };
-
- Or, if you want to initialize more rows at once, why not use:
-
- static struct FUNCTIONMAP functionlist[300] =
- {
- { "firstfunction", 1, 3, { 2, 2, 2, 0, 0 } },
- { "secondfunc", 1, 3, { 2, 2, 2, 0, 0 } },
- ... /* etc */
- };
-
- BTW, in C/C++, array indexes start at 0 instead of 1.
-
- Later,
- AriL
-
- All my opinions are mine and mine alone.
-
-